package com.flushbonading.service.impl;

import com.flushbonading.pojo.Score;
import com.flushbonading.mapper.ScoreMapper;
import com.flushbonading.pojo.dto.ScoreDTO;
import com.flushbonading.pojo.dto.ScoreMessageDTO;
import com.flushbonading.service.IScoreService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.flushbonading.util.DirectionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zlx
 * @since 2021-04-07
 */
@Service
public class ScoreServiceImpl extends ServiceImpl<ScoreMapper, Score> implements IScoreService {

    @Autowired
    private ScoreMapper scoreMapper;

    @Override
    public List<ScoreDTO> getSocresByCourseID(int course_id) {
        return scoreMapper.getSocresByCourseID(course_id);
    }

    @Override
    public int updateCourses(int course_id, ScoreDTO scoreDTO) {
        return scoreMapper.updateCourses(course_id,scoreDTO);
    }

    @Override
    public int updateAllScore() {
        return scoreMapper.updateAllScore();
    }

    @Override
    public int updateTotalScore(int course_id, ScoreDTO scoreDTO) {
        return scoreMapper.updateTotalScore(course_id,scoreDTO);
    }

    @Override
    public int deleteScoreByID(int course_id) {
        return scoreMapper.deleteCourse(course_id);
    }

    @Override
    public int deleteAScore(int course_id, String student_number) {
        return scoreMapper.deleteAScore(course_id, student_number);
    }

    @Override
    public int insertCourse(int course_id, String type) {
        return scoreMapper.insertCourse(course_id, DirectionUtil.directionID(type));
    }

    @Override
    public List<ScoreDTO> searchScore(int course_id, String student_number, String name) {
        return scoreMapper.searchScore(course_id, student_number, name);
    }

    @Override
    public List<ScoreMessageDTO> getScoresByStudentNumber(String student_number) {
        return scoreMapper.getScoresByStudentNumber(student_number);
    }
}
